package com.rjt.common.util;

import java.util.ArrayList;
import java.util.List;

import com.rjt.common.model.Address;
import com.rjt.common.service.IpAddress;
import com.rjt.common.service.impl.IpApiImpl;
import com.rjt.common.service.impl.TaobaoImpl;

public class IpUtils {
	private static List<IpAddress> list;
	static {
		list = new ArrayList<>();
		list.add(new TaobaoImpl());
		list.add(new IpApiImpl());
	}

	/**
	 * 根据IP获取地址信息
	 * 
	 * @param ip
	 * @return
	 */
	public static Address getAddress(String ip) {
		for (IpAddress ipAddress : list) {
			try {
				return ipAddress.getAddress(ip);
			} catch (Exception e) {
			}
		}
		return null;
	}
}
